<template>
    <div>
    
      <van-nav-bar title="会员登录" left-text="返回" left-arrow @click-left="()=>{$router.push('/zc')}" fixed/>
<van-empty description="描述文字" />

        <div style="height: 45px;"></div>
<van-form @submit="onSubmit">
  <van-cell-group inset>
    <van-field
      v-model="username"
      name="username"
      label="账号"
      placeholder="请输入账号"
      :rules="[{ required: true, message: '请输入账号' }]"
    />
    <van-field
      v-model="password"
      type="password"
      name="password"
      label="密码"
      placeholder="请输入密码"
      :rules="[{ required: true, message: '请输入密码' }]"
    />
  </van-cell-group>
  <div style="margin: 16px;">
    <van-button round block type="primary" native-type="submit">
    登录
    </van-button>
  </div>
</van-form>

    </div>
</template>

<script setup>

import { ref } from 'vue';
import{loginApi}from '@/api/api'
import { useRouter } from 'vue-router';
const router=useRouter()
    const username = ref('');
    const password = ref('');
    const onSubmit = () => {
      console.log( username.value, password.value);
      loginApi(username.value, password.value).then(res=>{
        console.log(res);
router.push('/zc')
      })
    };
</script>

<style lang="scss" scoped>

</style>